#!/usr/bin/env python
####### workaround so that the module is found #######
import sys
import os
sys.path.append(os.path.join(os.path.dirname(__file__),"../../src"))
######################################################

from rosinterface_handler.interface_generator_catkin import *
gen = InterfaceGenerator()

gen.add_verbosity_param("verbosity_param_w_default", configurable=False, default='info')
gen.add_diagnostic_updater(simplified_status=True)
gen.add_tf(buffer_name="tf_buffer", listener_name="tf_listener", broadcaster_name="tf_broadcaster")

# Parameters with different types
gen.add("int_param_w_default", paramtype="int", description="An Integer parameter", default=1, configurable=True)
gen.add("double_param_w_default", paramtype="double",description="A double parameter", default=1.1)
gen.add("str_param_w_default", paramtype="std::string", description="A string parameter", default="Hello World")
gen.add("bool_param_w_default", paramtype="bool", description="A Boolean parameter", default=True)
gen.add("long_param_w_default_int", paramtype="int64_t", description="A long parameter", default=1)
gen.add("long_param_w_default_int_str", paramtype="int64_t", description="A long parameter", default="-1")
# gen.add("long_param_w_default_long", paramtype="int64_t", description="A long parameter", default=9223372036854775807) # (2**63 - 1) would fail due to xmlrpc lib
gen.add("long_param_w_default_long_string", paramtype="int64_t", description="A long parameter", default="9223372036854775807L")

gen.add("vector_int_param_w_default", paramtype="std::vector<int>", description="A vector of int parameter", default=[1,2,3])
gen.add("vector_double_param_w_default", paramtype="std::vector<double>", description="A vector of double parameter", default=[1.1, 1.2, 1.3])
gen.add("vector_bool_param_w_default", paramtype="std::vector<bool>", description="A vector of bool parameter", default=[False, True])
gen.add("vector_string_param_w_default", paramtype="std::vector<std::string>", description="A vector of string parameter", default=["Hello", "World"])
gen.add("map_param_w_default", paramtype="std::map<std::string,std::string>", description="A map parameter", default={"Hello": "World"})

gen.add_enum("enum_int_param_w_default", description="enum", entry_strings=["Small", "Medium", "Large", "ExtraLarge"], default="Medium", paramtype='int')
gen.add_enum("enum_str_param_w_default", description="string enum", entry_strings=["Zero", "One", "Two", "Three"], default="One", paramtype='std::string')

p1 = gen.add_publisher("publisher_w_default", description="publisher", default_topic="out_topic", message_type="std_msgs::Header", configurable=True)
p2 = gen.add_publisher("publisher_diag_w_default", description="publisher", default_topic="out_point_topic", message_type="geometry_msgs::PointStamped", configurable=True, diagnosed=True)
p3 = gen.add_publisher("publisher_public_w_default", description="public publisher", default_topic="out_topic", message_type="std_msgs::Header", scope="public", configurable=True)
gen.add_publisher("publisher_global_w_default", description="global publisher", default_topic="out_topic", message_type="std_msgs::Header", scope="global", configurable=True)
gen.add_subscriber("subscriber_w_default", description="subscriber", default_topic="in_topic", message_type="std_msgs::Header", configurable=True)
gen.add_subscriber("subscriber_diag_w_default", description="subscriber", default_topic="in_point_topic", message_type="geometry_msgs::PointStamped", configurable=True, diagnosed=True)
gen.add_subscriber("subscriber_public_w_default", description="public subscriber", default_topic="in_topic", message_type="std_msgs::Header", scope="public", configurable=True)
gen.add_subscriber("subscriber_global_w_default", description="global subscriber", default_topic="in_topic", message_type="std_msgs::Header", scope="global", configurable=True)
gen.add_subscriber("subscriber_smart", description="smart subscriber", default_topic="in_topic2", message_type="geometry_msgs::PointStamped", watch=[p1, p2, p3], configurable=True)
gen.add_subscriber("subscriber_smart_diagnosed", description="smart diagnosed subscriber", default_topic="in_topic2", message_type="geometry_msgs::PointStamped", watch=[p1, p2, p3], diagnosed=True)

#Syntax : Package, Node, Config Name(The final name will be MyDummyConfig)
exit(gen.generate("rosinterface_handler", "rosinterface_handler_test", "Defaults"))
